	package edu.towson.cosc603.coffeemaker;
	 
	import org.junit.Test;
	 
import junit.framework.TestCase;
	 
	/**
	 *
	 */
	public class CoffeeMakerTest extends TestCase {
	        private CoffeeMaker cm;
	        private Inventory i;
	        private Recipe r1;
	        private Recipe r2;
	        private Recipe r3;
	        private Recipe r4;
	        private Recipe r5;
	        
	 
	        public void setUp() throws Exception {
	                cm = new CoffeeMaker();
	                i = cm.checkInventory();
	 
	                r1 = new Recipe();
	                r1.setName("Coffee");
	                r1.setPrice(50);
	                r1.setAmtCoffee(6);
	                r1.setAmtMilk(1);
	                r1.setAmtSugar(1);
	                r1.setAmtChocolate(2);
	                
	                r2 = new Recipe();
	                r2.setName("Cefe Mocha");
	                r2.setPrice(60);
	                r2.setAmtCoffee(6);
	                r2.setAmtMilk(2);
	                r2.setAmtSugar(2);
	                r2.setAmtChocolate(3);
	                
	                r3 = new Recipe();
	                r3.setName("Americano");
	                r3.setPrice(40);
	                r3.setAmtCoffee(6);
	                r3.setAmtMilk(2);
	                r3.setAmtSugar(2);
	                r3.setAmtChocolate(2);
	                
	                r4 = new Recipe();
	                r4.setName("Hot Chocolate");
	                r4.setPrice(55);
	                r4.setAmtCoffee(2);
	                r4.setAmtMilk(2);
	                r4.setAmtSugar(2);
	                r4.setAmtChocolate(6);
	                
	                r5 = new Recipe();
	                r5.setName("Milk Coffee");
	                r5.setPrice(30);
	                r5.setAmtCoffee(2);
	                r5.setAmtMilk(5);
	                r5.setAmtSugar(2);
	                r5.setAmtChocolate(2);
	        }
	 
	        @Test
	        public void testAddRecipe1() {
	                assertTrue(cm.addRecipe(r1));
	                assertTrue(cm.addRecipe(r2));
	                assertTrue(cm.addRecipe(r3));
	                assertTrue(cm.addRecipe(r4));
	                assertFalse(cm.addRecipe(r1));
	                assertFalse(cm.addRecipe(r5));
	        }
	 
	        @Test
	        public void testDeleteRecipe1() {
	                cm.addRecipe(r1);
	                assertTrue(cm.deleteRecipe(r1));
	        }
	 
	        @Test
	        public void testEditRecipe1() {
	                cm.addRecipe(r1);
	                Recipe newRecipe = new Recipe();
	                newRecipe = r1;
	                newRecipe.setAmtSugar(2);
	                assertTrue(cm.editRecipe(r1, newRecipe));
	                cm.addRecipe(r2);
	                cm.addRecipe(r3);
	                cm.addRecipe(r4);
	                assertFalse(cm.editRecipe(r1, r1));
	        }
	        
	        @Test
	        public void testAddInventory1() {
	                assertTrue(cm.addInventory(20, 40, 30, 50));
	                assertEquals(35, cm.checkInventory().getCoffee());
	                assertEquals(55, cm.checkInventory().getMilk());
	                assertEquals(45, cm.checkInventory().getSugar());
	                assertEquals(65, cm.checkInventory().getChocolate());
	                assertFalse(cm.addInventory(-1, 10, 10, 10));
	        }
	        
	        @Test
	        public void testMakeCoffee1() {
	                cm.addRecipe(r1);
	                assertEquals(50, cm.makeCoffee(r1, 100));
	                assertEquals(9, cm.checkInventory().getCoffee());
	                assertEquals(14, cm.checkInventory().getMilk());
	                assertEquals(14, cm.checkInventory().getSugar());
	                assertEquals(13, cm.checkInventory().getChocolate());
	                
	                assertEquals(50, cm.makeCoffee(r1, 100));
	                assertEquals(3, cm.checkInventory().getCoffee());
	                assertEquals(13, cm.checkInventory().getMilk());
	                assertEquals(13, cm.checkInventory().getSugar());
	                assertEquals(11, cm.checkInventory().getChocolate());
	                
	                assertEquals(100, cm.makeCoffee(r1, 100));
	                assertEquals(3, cm.checkInventory().getCoffee());
	                assertEquals(13, cm.checkInventory().getMilk());
	                assertEquals(13, cm.checkInventory().getSugar());
	                assertEquals(11, cm.checkInventory().getChocolate());
	                
	                assertEquals(20, cm.makeCoffee(r1, 20));
	                assertEquals(3, cm.checkInventory().getCoffee());
	                assertEquals(13, cm.checkInventory().getMilk());
	                assertEquals(13, cm.checkInventory().getSugar());
	                assertEquals(11, cm.checkInventory().getChocolate());
	        }
	        
	        @Test
	        public void testGetRecipe1() {
	                assertEquals(null, cm.getRecipes()[0].getName());
	        }
	        
	        @Test
	        public void testGetRecipeForName1() {
	                cm.addRecipe(r1);
	                assertEquals("Coffee", cm.getRecipeForName("Coffee").getName());
	        }
	        
	}